package com.ah.controller;

import com.ah.service.IPaymentService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    /**
     * @DubboReference
     * 1，标记Dubbo的服务引用，消费者贴上此注解，Dubbo服务在程序启动，就会将服务注入到当前这个消费者中
     * 2, Dubbo自动处理远程服务过程
     * 3，透明的远程服务调用，不需要关注细节。调用者直接调用即可
     **/

    /**
     * 属性说明
     * check = false 设置启动不检查服务提供者
     * timeout = 2000 这只超时时间为两秒
     * retries = 3 设置访问服务提供者失败后的重试次数
     * cluster集群容错策略
     * mock = "force:return null" 熔断，失败后返货null
     * **/
    @DubboReference(check = false,timeout = 2000,retries = 3,cluster = "failover",mock = "force:return null")
    private IPaymentService paymentService;

    @GetMapping("/getpayment")
    public String getPaymentStatus(){
        String result = paymentService.payment(13214351);
        return result;
    }
}
